import axios from 'axios';

const state = {
  testCases: null
};

const mutations = {
  SET_TEST_CASES(state, testCases) {
    state.testCases = testCases;
  }
};

const actions = {
  async generateTestCases({ commit }, { content }) {
    try {
      const response = await axios.post('/api/test-cases/generate', {
        content
      });
      commit('SET_TEST_CASES', response.data);
      return response;
    } catch (error) {
      throw error;
    }
  }
};

export default {
  state,
  mutations,
  actions
};